Skip to content

[Dotenv] Add SYMFONY_DOTENV_PATH #19371

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 3, 2024

Conversation

alexandre-daubois
Copy link
Member

Fix #19366

Copy link
Contributor

@OskarStark OskarStark left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Env var -> environment variable

@alexandre-daubois
Copy link
Member Author

Updated 👍

@javiereguiluz
Copy link
Member

Alex, thanks a lot for documenting this new feature so fast.

While merging I did some very minor changes ((e926d7c)) ... but I also promoted the mention about where to define this new env var to a caution because I think this is important to avoid readers frustration (e.g. if they define this env var in the default .env file thinking that Symfony will read that value and load the custom file).

@alexandre-daubois
Copy link
Member Author

Thanks Javier!

@alexandre-daubois alexandre-daubois deleted the dotenv-env-var branch January 3, 2024 17:07
@GromNaN
Copy link
Member

GromNaN commented Jan 3, 2024

Hello and sorry, this feature has been misinterpreted. The variable can't be set before calling DotEnv. It's only an internal variable, like SYMFONY_DOTENV_VARS, that is set by the DotEnv class when a file is loaded.
You can document how to change the path to the .env file:

The custom path can be set in many ways:

  • Doing a call to (new Dotenv())->bootEnv(dirname(__DIR__).'my/custom/path/to/.env');
  • In composer.json: "extra": { "runtime": { "dotenv_path": "my/custom/path/to/.env" }
  • With the env var: $_SERVER['APP_RUNTIME_OPTIONS'] = ['dotenv_path' => 'my/custom/path/to/.env'];

@alexandre-daubois
Copy link
Member Author

I'll send another PR to fix this, thanks for the explanation Jérôme!

javiereguiluz added a commit that referenced this pull request Jan 31, 2024
…e-daubois)

This PR was merged into the 7.1 branch.

Discussion
----------

[Dotenv] Fix incorrect way to modify .env path

After #19371 (comment)

Commits
-------

3ee6a7f [DotEnv] Fix incorrect way to modify .env path
@nicolas-grekas
Copy link
Member

I'm sorry but this description is wrong. This var is not about changing the location of the dot env files. It's about exposing where the dotenv files are so that the apps itself can know about it.
/cc @GromNaN

OskarStark added a commit that referenced this pull request May 30, 2024
…ubois)

This PR was merged into the 7.1 branch.

Discussion
----------

[Dotenv] Fix `SYMFONY_DOTENV_PATH` purpose

After #19371 (comment), sorry for the misunderstanding on this feature!

I guess https://symfony.com/blog/new-in-symfony-7-1-misc-improvements-part-2#custom-env-path will also need an update.

cc `@nicolas`-grekas

Commits
-------

41c4ce5 [Dotenv] Fix `SYMFONY_DOTENV_PATH` purpose
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Dotenv] Add SYMFONY_DOTENV_PATH, consumed by debug:dotenv for cust…
6 participants